USE [BDPAutodetect]
GO

CREATE VIEW [dbo].[V_Basic_Role]
AS 
SELECT [ID],[Code],[Name],[Supered],[Enabled],[CreateTime],[UpdateTime]
FROM [dbo].[T_Basic_Role] 
WHERE [Deleted] = 0;
GO

CREATE VIEW [dbo].[V_Basic_Power]
AS 
SELECT A.[ID],A.[Code],A.[Name],A.[ParentID],A.[MenuStatus],A.[TreeStatus],A.[URL],A.[Inco],A.[Enabled],A.[CreateTime],A.[UpdateTime]
FROM [dbo].[T_Basic_Power] AS A
WHERE A.[Deleted] = 0;
GO

CREATE VIEW [dbo].[V_Basic_RolePowerRelation]
AS 
SELECT A.[ID],A.[RoleID],B.[Code] AS [RoleCode],B.[Name] AS [RoleName],A.[PowerID],C.[Code] AS [PowerCode],C.[Name] AS [PowerName],C.[ParentID] AS [PowerParentID],C.[MenuStatus],C.[TreeStatus],C.[URL],C.[Inco],B.[Supered]
FROM [dbo].[T_Basic_RolePowerRelation]  AS A 
LEFT JOIN [dbo].[T_Basic_Role] AS B ON B.[ID] = A.[RoleID] 
LEFT JOIN [dbo].[T_Basic_Power] AS C ON C.[ID] = A.[PowerID] 
WHERE A.[Deleted] = 0 AND B.[Deleted] = 0 AND C.[Deleted] = 0;
GO

CREATE VIEW [dbo].[V_Basic_User]
AS 
SELECT A.[ID],A.[Code],A.[Name],A.[NameNick],A.[Password],A.[RoleID],B.[Name] AS [RoleName],A.[Gender],A.[Freezed],A.[Logined],A.[Enabled],A.[CreateTime],A.[UpdateTime]
FROM [dbo].[T_Basic_User] AS A 
LEFT JOIN [dbo].[T_Basic_Role] AS B ON B.[ID] = A.[RoleID]
WHERE A.[Deleted] = 0 AND B.[Deleted] = 0;
GO










